<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <script src="../lib/vue.js"></script>
  </head>

  <body>
    <div id="app">
      <cpn></cpn>
      <cpn></cpn>
      <cpn></cpn>
    </div>
    <template id="cpnt">
      <div>
        <h2>我是计算器组件</h2>
        <p>
          <button @click="increase">+</button
          ><button @click="decrease">-</button>
        </p>
        <p>我是组件内容：当前计数:{{count}}</p>
      </div>
    </template>
    <script>
      //1.注册组件
      Vue.component('cpn', {
        template: '#cpnt',
        data() {
          return {
            count: 0
          }
        },
        methods: {
          increase() {
            this.count++
          },
          decrease() {
            this.count--
          }
        }
      })
      var vm = new Vue({
        el: '#app',
        data: {},
        methods: {}
      })
    </script>
  </body>
</html>
